/**
 * Created by Dalyn on 2017/3/25.
 */
import React, {Component}from 'react';
import Relay from "react-relay";
import {Modal} from "antd";
import "./css/payment.css";
import InputBox from "../../common/InputBox";
import Confirm from "../../common/Confirm";
// import BatchUpdateLoanInfoMutation from "./mutation/BatchUpdateLoanInfoMutation"

export default class LoanBomb extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            displayflag: true,
        };
        this.style = {
            confirm: {
                width: '60px',
                height: '30px',
                backgroundColor: "#1b3249",
                fontSize: "18px",
                color: "#fff",
                marginTop: "16px",
                marginLeft: "20px",
                fontFamily: "Microsoft YaHei"
            },
        };
        this.isshow = 'none';
        this.isRelay = true
    }

    componentWillMount() {

    }

    /*操作成功提示*/
    success() {
        this.props._success();
    }

    /*点击确认*/
    handleConfirm(flag) {
        this.props._loanPayOrder();
    }

    handleCancel(flag) {
        this.setState({
            displayflag: !flag
        });
    }

    render() {
        return (
            <div className="trade_hint_bg0">
                {
                    this.props._errorCode == "0"
                        ?
                        (
                            <Modal title="借款" visible={!this.state.displayflag} style={{top: '20%'}}
                                   wrapClassName="tradepay_hint_modal"
                                   onOk={this.handleConfirm.bind(this, this.state.displayflag)}
                                   onCancel={this.handleCancel.bind(this, this.state.displayflag)}
                                   okText="确定" cancelText="取消"
                            >
                                <div className="trade_batchHint1">
                                    <div className="payment_bomb_payInfo">
                                        <p className="payment_pro_p">
                                            <span className="payment_pro_bomb_span">借款用途：</span>
                                            <span className="payment_pro_bomb_span">支付订单</span>
                                            <span className="payment_pro_bomb_span">{this.props._orderId}</span>
                                        </p>
                                        <p className="payment_pro_p">
                                            <span className="payment_pro_bomb_span">借款金额：</span>
                                            <span
                                                className="payment_pro_bomb_span">{parseFloat(this.props._loanMoney).toFixed(2)}</span>
                                            <span className="payment_pro_bomb_span">元</span>
                                        </p>
                                        <p className="payment_pro_p">
                                            <span className="payment_pro_bomb_span">日利率：</span>
                                            <span className="payment_pro_bomb_span">{this.props._dayRate}</span>
                                            <span className="payment_pro_bomb_span">%</span>
                                        </p>
                                        <p className="payment_pro_p"><span
                                            className="payment_pro_bomb_span">还款方式：订单结算时自动扣除本金和利息</span></p>
                                    </div>
                                </div>
                            </Modal>
                        )
                        :
                        (
                            <Modal title="借款" visible={!this.state.displayflag} style={{top: '20%'}}
                                   wrapClassName="tradepay_hint_modal"
                                   onOk={this.handleCancel.bind(this, this.state.displayflag)}
                                   onCancel={this.handleCancel.bind(this, this.state.displayflag)}
                                   okText="确定" cancelText="取消"
                            >
                                <div className="trade_batchHint2">
                                    <div className="payment_bomb_payInfo">
                                        <p className="payment_pro_p">
                                            <span className="payment_pro_bomb_span">{this.props._hint?this.props._hint:"无法借款"}</span>
                                        </p>
                                    </div>
                                </div>
                            </Modal>
                        )
                }
            </div>
        )
    }
}